<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:cc="http://java.sun.com/jsf/composite">

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="title" />
        <cc:attribute name="value" />
        <cc:attribute name="style" />
        <cc:attribute name="label" />
        <cc:attribute name="labelAlign" default="top" shortDescription="[top|left]" />
        <cc:attribute name="styleClassLabel" default="labels" /> 
        <cc:attribute name="styleClassInput" default="input" /> 
        <cc:attribute name="styleClassError" default="errors" /> 
        <cc:attribute name="rows" type="int" default="2" />
        <cc:attribute name="cols" type="int" default="80" />
        <cc:attribute name="maxlength" type="int" default="15" />
        <cc:attribute name="valid" type="boolean" default="true" />
        <cc:attribute name="required" type="boolean" /> 
        <cc:attribute name="readonly" type="boolean" /> 
        <cc:attribute name="converter" /> 
        <cc:attribute name="tipoConverter" />
        <cc:attribute name="onChangeUpdate" />
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <c:set var="cid" value="#{cc.attrs.id}_textarea" />
        <h:panelGrid columns="#{cc.attrs.labelAlign == 'left' ? 2 : 1}">
            <h:outputLabel for="#{cid}" rendered="#{!empty cc.attrs.label}"
                           styleClass="#{cc.attrs.styleClassLabel}"
                           value="#{cc.attrs.label}" />
            <h:panelGrid columns="2">
                <f:validateBean disabled="#{!cc.attrs.valid}">
                    <h:inputTextarea id="#{cid}" label="#{cc.attrs.label}" cols="#{cc.attrs.cols}" rows="#{cc.attrs.rows}" readonly="#{cc.attrs.readonly}" value="#{cc.attrs.value}"
                                     title="#{cc.attrs.valid and !jsfManager.valid(cid) ? jsfManager.getErrorMsg(cid) : (empty cc.attrs.title ? cc.attrs.label : cc.attrs.title)}"
                                     styleClass="ui-inputfield ui-state-default ui-corner-all #{cc.attrs.valid and !jsfManager.valid(cid) ? cc.attrs.styleClassError : cc.attrs.styleClassInput}"
                                     onkeyup="limitarTamanho(this, #{cc.attrs.maxlength})" onblur="limitarTamanho(this, #{cc.attrs.maxlength})" style="#{cc.attrs.style}">
                        <c:if test="#{!empty cc.attrs.converter}">
                            <f:converter converterId="#{cc.attrs.converter}" />
                        </c:if> 
                        <c:if test="#{!empty cc.attrs.converter and !empty cc.attrs.tipoConverter}">
                            <f:attribute name="type" value="#{cc.attrs.tipoConverter}" />
                        </c:if>
                        <c:if test="#{!empty cc.attrs.onChangeUpdate}">
                            <p:ajax event="change" update="#{cc.attrs.onChangeUpdate}" />
                        </c:if>
                        <cc:insertChildren />
                    </h:inputTextarea>
                </f:validateBean>
                <h:graphicImage rendered="#{cc.attrs.required}" library="images" name="required.gif" styleClass="imgCampoObrigatorio" />
            </h:panelGrid>
        </h:panelGrid>
    </cc:implementation>
</html>
